为了通过AnnoTemplate(在线文档'AnnoTemplate属性')属性创建一个自定义标注,请使用以下XAML标注或者C#代码:
XAML |
拷贝代码
|
---|---|
<c1chart:ChartView.AxisX> <c1chart:Axis> <c1chart:Axis.Resources > <local:ColorConverter x:Key="clrcnv" /> </c1chart:Axis.Resources> <c1chart:Axis.AnnoTemplate> <DataTemplate> <TextBlock Width="25" TextAlignment="Center" Text="{Binding Path=Value}" Foreground="{Binding Converter={StaticResource clrcnv}}"/> </DataTemplate> </c1chart:Axis.AnnoTemplate> </c1chart:Axis> </c1chart:ChartView.AxisX> |
C# |
拷贝代码
|
---|---|
public class ColorConverter : IValueConverter { int cnt = 0; public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { //DataPoint dpt = (DataPoint)value; //交替画刷颜色 return cnt++ % 2 == 0 ? Brushes.Blue : Brushes.Red; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { return null; } } |